var QQMapWx = require("../../libs/qqmap-wx-jssdk")
var qqmapsdk = new QQMapWx({
  key: 'E5ZBZ-53ZCV-NBKP5-5UKXB-RBH2F-UOBXY'
})
// pages/my/my.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    TabCur: 0,
    scrollLeft:0,
    // https://yz.lol.qq.com/v1/assets/videos/aatrox-splashvideo.webm
    userinfo: {
    
    },
    tablist:["笔记","收藏","赞过"],
    noramalData: [
      {
        id:"101",
        cover: "/images/sucai/_1_王小二cy_来自小红书网页版.jpg",
        title: "#赣州马拉松 #显眼包赣州马拉松的显眼包们 哈哈哈哈哈",
        tx: "/images/sucai/头像.webp",
        name: "王小二cy",
        num: "1000000",
        islike: 1,
        tran_num: "",
        tag: ["穿搭", "推荐"]
      },
      {
        id:"102",
        cover: "/images/sucai/_1_小红薯673D6FB4_来自小红书网页版 (1).jpg",
        title: "",
        tx: "/images/sucai/645b807d338379fac18930a8.png",
        name: "小红薯673D6FB4",
        num: "888",
        islike: 0,
        tran_num: "",
        tag: ["穿搭", "情感", "推荐"]
      },
      {
        id:"100",
        cover: "/images/sucai/物理老师打篮球一百个只进了三个_1_蛤？_来自小红书网页版.jpg",
        title: "物理老师打篮球一百个只进了三个逊爆了还ikun，但是长的真的很帅#物理老师#坤坤",
        tx: "/images/sucai/1040g2jo30rk4cc0aiq6g5o3altr08utqq3qokq0.webp",
        name: "ha",
        num: "178",
        islike: 1,
        tran_num: "",
        tag: ["穿搭", "职场", "推荐"]
      },
    ]
  },
  onLoad(options) {
    
},
tabSelect(e) {
  this.setData({
    TabCur: e.currentTarget.dataset.id,
    scrollLeft: (e.currentTarget.dataset.id-1)*60
  })
},

  onShow() {
    this.getUserInfo()
  },
  toSet(){
    wx.navigateTo({
      url: "/pages/setDetail/setDetail",
    })
  },
  getUserInfo(){
    let user = wx.getStorageSync('userInfo')
    console.log(user)
    if (user == "") {
      console.log()
      user = {
        bg: "/images/sucai/_1_小红薯673D6FB4_来自小红书网页版 (1).jpg",
        headerUrl: "/images/icon/me_select .png",
        username: "请点击头像登录",
        code: "",
        IP_address: "",
        detail: "",
        sex: "",
        taglist: "",
      }
      this.setData({
        userinfo:user
      })
    }else{
      this.getIP()
      this.setData({
        userinfo:user
      })
    }
  },
  getIP(){
    let that = this
    wx.getFuzzyLocation({
        type: 'wgs84',
        success(res) {
            that.setData({
                location: res.latitude + "," + res.longitude
            })
            qqmapsdk.reverseGeocoder({
                location: that.data.location,
                success: function (res) { //成功后的回调
                  console.log(res)
                    let province = res.result.address_component.province
                    province = province.substring(0,2)
                    let user = that.data.userinfo
                    user.IP_address = province
                    that.setData({
                        userinfo:user
                    })
                }
            })
        }
    })
  },
  toLogin(){
    wx.navigateTo({
      url: '/pages/login/login',
    })
  }
})